<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // function Person(){
        //     this.say = function(){

        //     }
        // }

        // Perons.prototype.eat = function(){

        // }


        class Person{
            state = {
                count:0
            }
            say = function(){
                console.log('say this: ', this);
            }

            test = ()=>{
                console.log('test this: ', this);
            }

            // constructor(){
            //     this.test = ()=>{
            //         console.log('test this: ', this);
            //     }
            // }

            eat(){ // 定义在Person.prototype.eat
                console.log('eat this: ', this);
            }
        }

        const p1 = new Person();
        const p2 = new Person();

        p1.say();
        p1.eat();
        p2.say();
        p2.eat();

        console.log(p1.say === p2.say, p1.eat === p2.eat);


        let obj = {
            fn:p1.say,
            fnTest: p1.test
        }

        obj.fn();

        p1.test();

        obj.fnTest();

    </script>
</body>
</html>